package com.hotelsystem.reservations.creators;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Scanner;

import com.hotelsystem.reservations.rooms.Room;
import com.hotelsystem.reservations.rooms.RoomTypesEnum;

public class RoomCreator {

	/**
	 * First add room number then room type (1.ONE_PERSON_ROOM,
	 * 2.TWO_PERSONS_ROOM, 3.SUITE, 4.LUXE_SUITE 5.PRESIDENTIAL_SUITE) and
	 * lastly add boolean if the room is smokers free
	 * 
	 * @param in
	 *            input stream
	 * @return New Room. Returns null if room type is diferent from 1,2,3,4 or 5
	 */
	public Room readRoom(InputStream in) {
		@SuppressWarnings("resource")
		Scanner input = new Scanner(in);
		System.out.println("1.ONE_PERSON_ROOM," + "2.TWO_PERSONS_ROOM, 3.SUITE, 4.LUXE_SUITE 5.PRESIDENTIAL_SUITE");
		int roomNumber = input.nextInt();

		int roomTypeNum = input.nextInt();

		RoomTypesEnum roomType = null;

		switch (roomTypeNum) {
		case 1:
			roomType = RoomTypesEnum.ONE_PERSON_ROOM;
			break;
		case 2:
			roomType = RoomTypesEnum.TWO_PERSONS_ROOM;
			break;
		case 3:
			roomType = RoomTypesEnum.SUITE;
			break;
		case 4:
			roomType = RoomTypesEnum.LUXE_SUITE;
			break;
		case 5:
			roomType = RoomTypesEnum.PRESIDENTIAL_SUITE;
			break;
		default:
			return null;
		}

		boolean isSmokersFree = input.nextBoolean();
		
		String imageFilePath = input.next();
		
		return new Room(roomNumber, roomType, isSmokersFree, imageFilePath);
	}

}
